/* 最大流拆点
* 1.解题思路 
    
* 本题:
    左边为食物，中间为奶牛，右边为饮料，对于每一奶牛，向左边它喜欢的食物建反向边，向右边它喜欢的饮料建边，容量都为1

    会有好多流量经过同一个奶牛表示的点,对这部分点拆点: 将一头牛拆成两个点-入点（食物）和出点（饮料）。然后入点连到出点的边容量为1，这样就可以保证经过一头牛的流量小于等于1
    

*/

#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
using namespace std;
const int N = 410, M = 40610, INF = 0x3f3f3f3f;

int n, F, D, S, T;
int h[N], e[M], c[M], ne[M], idx;
int q[N], d[N], cur[N];

void AddEdge(int a, int b, int w)
{
    e[idx] = b, c[idx] = w, ne[idx] = h[a], h[a] = idx++;
    e[idx] = a, c[idx] = 0, ne[idx] = h[b], h[b] = idx++;
}

bool bfs()
{
    memset(d, -1, sizeof d);
    int hh = 0, tt = -1;
    q[++tt] = S, d[S] = 0, cur[S] = h[S];
    while(hh <= tt)
    {
        int u = q[hh++];
        for(int i = h[u]; ~i; i = ne[i])
        {
            int v = e[i];
            if(d[v] == -1 && c[i])
            {
                d[v] = d[u]+1;
                cur[v] = h[v];
                if(v == T) return true;
                q[++tt] = v;
            }
        }
    }
    return false;
}

int find(int u, int limit)
{
    if(u == T) return limit;
    int flow = 0;
    for(int i = cur[u]; ~i && flow < limit; cur[u] = i, i = ne[i])
    {
        int v = e[i];
        if(d[v] == d[u] + 1 && c[i])
        {
            int t = find(v, min(c[i], limit-flow));
            if(!t) d[v] = -1;
            c[i] -= t, c[i^1] += t, flow += t;
        }
    }
    return flow;
}

int Dinic()
{
    int r = 0, flow;
    while(bfs())
        while(flow = find(S, INF)) r += flow;
    return r;
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    cin >> n >> F >> D;
    S = 0, T = 2*n+F+D+1;
    memset(h, -1, sizeof h);

    for(int i = 2*n+1; i <= 2*n+F; i++) AddEdge(S, i, 1);
    for(int i = 2*n+F+1; i <= 2*n+F+D; i++) AddEdge(i, T, 1);
    
    for(int i = 1; i <= n; i++)
    {
        int f, d; cin >> f >> d; //食物 饮料
        AddEdge(i, n+i, 1);
        int x;
        while(f--)
        {
            cin >> x; AddEdge(2*n+x, i, 1);
        }
        while(d--)
        {
            cin >> x; AddEdge(n+i, 2*n+F+x, 1);
        }
    }

    printf("%d\n", Dinic());
    return 0;
}